<style>
	a.teacher_link{
		font-size: 20px;
	}
	
	a.download_file:hover{
		color: #418a9f;
	}
	
	td.file{
		font-size: 11px;
	}
</style>
<?php
	$type = '';
	if(isset($flag))
	{
		switch($flag)
		{
			case 1:
				$type = 'Grading Period';
				break;
			case 2:
				$type = 'Grade Level';
				break;
			case 3:
				$type = 'Section';
				break;
			default:
				break;
		}
	}
?>
<div class="row">
<div class="panel callout"><h6>View Lessons</h6></div>
	<?$param = $this->uri->segment(3);?>
	<?if($param != ''):?>
		<?require('navigation/lesson_nav.php');?>
	<?else:?>
		<a href="<?=site_url(array('teacher','add_lesson'));?>" class="button small success">Add Lesson</a>
	<?endif;?>
		
	<?if(isset($system_message))echo $system_message;?>
	
	<div class="row">
		<div class="large-12 columns">
			<div class="row collapse">
				<div class="small-9 columns">
					<input type="text" placeholder="Search Lessons">
				</div>
				<div class="small-3 columns">
					<a href="#" class="button prefix">Search</a>
				</div>
			</div>
		</div>
	</div>
	
	
	<?if(isset($lesson_data)):?>
		<div class="panel"><h6>Viewing Lessons by: <?=$type;?></h6></div>
		
		<?if(!empty($index)):?>
			<div id="subj_accordion">
				<?foreach($index AS $i => $v):?>
					<h3><?=ucwords($v['desc']);?></h3>
					<div>
						<table>
							<thead>
								<tr>
									<th width="100">Lesson Title</th>
									<th width="100">Lesson Description</th>
									<th width="150">Lesson File</th>
									<th width="200"><center>Action</center></th>
								</tr>
							</thead>
							<tbody>
								<?if(!empty($lesson_data)):?>
									<?foreach($lesson_data AS $l):?>
										<?if($flag == 1):?>
											<?if($l->gp_id == $v['id']):?>
												<tr>
													<td><?=$l->lesson_title;?></td>
													<td><?=$l->lesson_desc;?></td>
													<td class="file"><a href="<?=site_url(array('teacher','download_file',$l->lesson_id));?>" title="Click to download" class="download_file"><?=$l->lesson_file_name;?></a></td>
													<td>
														<ul class="button-group">
															<li><a href="<?=site_url(array('teacher','edit_lesson', $l->lesson_id));?>" class="button tiny">View/Edit</a></li>
															<li><a href="<?=site_url(array('teacher','delete_lesson',$l->lesson_id, $flag));?>" class="button tiny alert confirm_btns">Delete</a></li>
														</ul>
													</td>
												</tr>
											<?endif;?>
										<?elseif($flag == 2):?>
											<?if($l->lvl_id == $v['id']):?>
												<tr>
													<td><?=$l->lesson_title;?></td>
													<td><?=$l->lesson_desc;?></td>
													<td  class="file"><?=$l->lesson_file_name;?></td>
													<td>
														<ul class="button-group">
															<li><a href="<?=site_url(array('teacher','edit_lesson', $l->lesson_id));?>" class="button tiny">View/Edit</a></li>
															<li><a href="<?=site_url(array('teacher','delete_lesson',$l->lesson_id, $flag));?>" class="button tiny alert confirm_btns">Delete</a></li>
														</ul>
													</td>
												</tr>
											<?endif;?>
										<?else:?>
											<?if($l->section_id == $v['id']):?>
												<tr>
													<td><?=$l->lesson_title;?></td>
													<td><?=$l->lesson_desc;?></td>
													<td  class="file"><?=$l->lesson_file_name;?></td>
													<td>
														<ul class="button-group">
															<li><a href="<?=site_url(array('teacher','edit_lesson', $l->lesson_id));?>" class="button tiny">View/Edit</a></li>
															<li><a href="<?=site_url(array('teacher','delete_lesson',$l->lesson_id, $flag));?>" class="button tiny alert confirm_btns">Delete</a></li>
														</ul>
													</td>
												</tr>
											<?endif;?>
										<?endif;?>
									<?endforeach;?>
								<?else:?>
									<div data-alert class="alert-box alert">No lessons yet.</div>
								<?endif;?>
							</tbody>
						</table>
					</div>
				<?endforeach;?>
			</div>
		<?else:?>
			<div data-alert class="alert-box">No lessons in this category.</div>
		<?endif;?>
	<?else:?>
		<div class="panel"><h6>View Lessons by: </h6></div>
		
		
			
		<div class="row">
			<div class="large-12 columns">
				<a href="<?=site_url(array('teacher', 'view_lesson',1));?>" class="teacher_link"> Grading Period </a>
			</div>
		</div>
		<br />
		<div class="row">
			<div class="large-12 columns">
				<a href="<?=site_url(array('teacher', 'view_lesson',2));?>" class="teacher_link"> Grade Level </a>
			</div>
		</div>
		<br />
		<div class="row">
			<div class="large-12 columns">
				<a href="<?=site_url(array('teacher', 'view_lesson',3));?>" class="teacher_link"> Section </a>
			</div>
		</div>
	<?endif;?>
</div>